package com.yunxiangyue.info_user

import android.content.Intent
import androidx.appcompat.app.AppCompatActivity
import android.os.Bundle
import android.view.Menu
import android.view.MenuItem
import android.widget.EditText
import com.yunxiangyue.app.R


class university_activity : AppCompatActivity() {
    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        setContentView(R.layout.activity_university)

        val actionBar=supportActionBar
        if(actionBar!=null){
//            设置ActionBar是否显示返回键
            actionBar.setDisplayHomeAsUpEnabled(true)
//            导入返回键图片
            actionBar.setHomeAsUpIndicator(R.drawable.ic_fanhui_2)
//            设置是否显示标题
            actionBar.setDisplayShowTitleEnabled(true)
            actionBar.setTitle("修改大学名称")
        }
    }

    override fun onOptionsItemSelected(item: MenuItem): Boolean {
        when(item.itemId){
            android.R.id.home -> finish()
            R.id.save -> {
                val intent= Intent()
                intent.putExtra("university",findViewById<EditText>(R.id.rectify_university).text.toString())
                setResult(2,intent)
                finish()
            }
        }
        return super.onOptionsItemSelected(item)
    }

    override fun onCreateOptionsMenu(menu: Menu?): Boolean {
        menuInflater.inflate(R.menu.save_name,menu)
        return super.onCreateOptionsMenu(menu)
    }
}